import { RouteRecordRaw } from 'vue-router'

const routes: RouteRecordRaw[] = [
  {
    path: '/',
    name: 'Home',
    meta: {
      title: '首页'
    },
    redirect: '/main'
  },
  {
    path: '/main',
    redirect: '/panel'
  },
  {
    path: '/panel',
    name: 'Workspace',
    component: () => import('pages/Workspace.vue'),
    meta: {
      title: '主面板'
    }
  },
  // 工具箱
  {
    path: '/apps',
    name: 'Apps',
    meta: { title: '工具推荐主页' },
    redirect: '/apps/search' // 相当于search就是下面AppIndex的一个特殊index
  },
  {
    path: '/apps/:index',
    name: 'AppIndex',
    component: () => import('pages/Tool.vue'),
    children: [
      {
        path: 'tool-detail/:toolId',
        name: 'AppDetail',
        component: () => import('pages/tool/TheToolDetailDialog.vue'),
        meta: {
          title: '工具详情'
        }
      }
    ]
  },
  {
    path: '/topic',
    name: 'Topic',
    meta: { title: '专题' },
    component: () => import('pages/Topic.vue')
  },
  {
    path: '/setting',
    name: 'Setting',
    meta: { title: '用户设置-51提效' },
    component: () => import('pages/user/Setting.vue')
  },
  {
    path: '/login',
    name: 'Login',
    meta: { title: '用户登录-51提效' },
    component: () => import('pages/Login.vue')
  },
  {
    path: '/registry',
    name: 'Registry',
    meta: { title: '用户注册-51提效' },
    props: {
      fromVisitor: true
    },
    component: () => import('pages/Login.vue')
  },
  {
    path: '/grid',
    name: 'Grid',
    meta: { title: 'GridTest' },
    props: {},
    component: () => import('pages/GridTest.vue')
  },
  {
    path: '/km',
    name: 'KM',
    meta: { title: '知识库' },
    props: {},
    component: () => import('pages/km/KM.vue'),
    children: [
      {
        path: 'article',
        name: 'Article',
        component: () => import('pages/km/KM.vue'),
        meta: {
          title: '文章列表'
        }
      }
    ]
  },
  {
    path: '/km/create',
    name: 'CreateKM',
    props: {
      id: String
    },
    component: () => import('pages/km/Create.vue'),
    meta: {
      title: '创建内容'
    }
  },
  {
    path: '/msg',
    name: 'Message',
    props: {},
    component: () => import('pages/msg/Channel.vue'),
    meta: {
      title: '维护消息通道'
    }
  },
  {
    path: '/subscribe',
    name: 'Subscribe',
    props: {},
    component: () => import('pages/km/tophub/Subscribe.vue'),
    meta: {
      title: '订阅管理'
    }
  },
  {
    path: '/z/:to',
    name: 'redirect',
    props: {},
    component: () => import('pages/redirect/redirect.vue'),
    meta: {
      title: '订阅管理'
    }
  },
  // Always leave this as last one,
  // but you can also remove it
  {
    path: '/:catchAll(.*)*',
    component: () => import('pages/Error404.vue')
  }
]

export default routes
